/* ===== welcome =====：欢迎页 */
myApp.onPageInit('welcome', function (page) {
	console.log('welcome');
});

/* ===== login =====：登录页 */
myApp.onPageInit('login', function (page) {
	console.log('login');
	$$('#login .tab .row a').click(function(){
		$$('#login .tab .col-50_active').removeClass('col-50_active');
		$$(this).parent().addClass('col-50_active');
	});
	//密码可见
	$$('#login .eye').click(function(){
		if($$(this).hasClass('active')){
			$$(this).attr('src','img/login/eye.png');
			$$(this).removeClass('active');
			$$(this).parent().find('input').attr('type','password');
		}else{
			$$(this).attr('src','img/login/eye-active.png');
			$$(this).addClass('active');
			$$(this).parent().find('input').attr('type','text');
		}
	});

	$$('#login .login_tourist_submit').click(function(){
		var login_tourist_name = $$('#login .login_tourist input[name="user"]').val();
		var login_tourist_pwd = $$('#login .login_tourist input[name="pwd"]').val();
        $$.ajax({
            url:url_post_touristlogin,
            method:"POST",
            data: {
                utype:'TOURIST',//,GUIDER)
                password:login_tourist_pwd,// 密码
                phoneNum:login_tourist_name//手机号/邮箱
            },
            dataType:'json',
            xhrFields:{withCredentials:true},
            success: function (ajaxresult) {
            //获取数据
                if(ajaxresult.code==1){
                    myApp.alert("登录成功！");
                    mainView.router.load({
                        "url":"index.html"
                    }); 
                }else{
                    ajaxfail(ajaxresult.msg);
                }
            },
        });           	
	});
	$$('#login .login_parnter_submit').click(function(){
		var login_parnter_name = $$('#login .login_parnter input[name="user"]').val();
		var login_parnter_pwd = $$('#login .login_parnter input[name="pwd"]').val();
		console.log(login_parnter_name,login_parnter_pwd);
        $$.ajax({
            url:url_post_touristlogin, 
            method:"POST",
            dataType:"json",
            xhrFields:{withCredentials:true},
            data:{
                utype:'GUIDER',
                password:login_parnter_pwd,// 密码
                phoneNum:login_parnter_name//手机号/邮箱
            },
            success: function (ajaxresult) {
                //获取数据
                if(ajaxresult.code==1){
                    myApp.alert("登录成功！");
                    mainView.router.load({
                        "url":"index.html"
                    });
                }else{
                    ajaxfail(ajaxresult.msg);
                }
            },
        });        
	});
});